﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Ivy.SiteAdmin.Entity;
using Ivy.SiteAdmin.DataAccess;
using Ivy.SiteAdmin.IBusinessLogic;

namespace Ivy.SiteAdmin.BusinessLogic
{
   public class SiteAdminBus : ISiteAdminBus
   {
       #region  Variable & constant
       #endregion  Variable & constant

       #region Constructor & Destructor
       #endregion Constructor & Destructor

       #region Properties
       #endregion Properties

       #region Public Methods
       #region ISiteAdminBus Members
       public bool AddNewResource(ResourceStat ResourceStatEntity)
       {
           bool IsOperationSuccessful = false;
          
               ResourceStatDao lResourceStatDao = new ResourceStatDao();
               IsOperationSuccessful = lResourceStatDao.Insert(ResourceStatEntity);
           
           return IsOperationSuccessful;

       }

       public bool UpdateResource(ResourceStat ResourceStatEntity)
       {
           bool IsOperationSuccessful = false;
           
               ResourceStatDao lResourceStatDao = new ResourceStatDao();
               IsOperationSuccessful = lResourceStatDao.Update(ResourceStatEntity);
           
           return IsOperationSuccessful;
       }

       public ResourceStat GetSelectedResourceByKey(int ResourceKey)
       {
               ResourceStatDao lResourceStatDao = new ResourceStatDao();
               ResourceStat lResourceStat;
               lResourceStat = lResourceStatDao.GetByResourceKey(ResourceKey);

               if (lResourceStat == null)
               {
                   return null;
               }
               else
               {
                   return lResourceStat;
               }
           
       }


       public bool RegisterNewSubscription(SubscriptionMaster SubscriptionMasterEntity)
       {
           bool IsOperationSuccessful = false;
          
               SubscriptionMasterDao lSubscriptionMasterDao = new SubscriptionMasterDao();
               IsOperationSuccessful = lSubscriptionMasterDao.Insert(SubscriptionMasterEntity);
           
           return IsOperationSuccessful;

       }

       public SubscriptionMaster GetBySubscribKey(int SubscribKey)
       {

           
               SubscriptionMasterDao lSubscriptionMasterDao = new SubscriptionMasterDao();
               SubscriptionMaster lSubscriptionMaster;
               lSubscriptionMaster = lSubscriptionMasterDao.GetByKey(SubscribKey);

               if (lSubscriptionMaster == null)
               {
                   return null;
               }
               else
               {
                   return lSubscriptionMaster;
               }
          
       }

       public List<SubscriptionMaster> GetAllSubscription()
       {
           List<SubscriptionMaster> lSubscriptionMasterList = new List<SubscriptionMaster>();
              SubscriptionMasterDao lSubscriptionMasterDao = new SubscriptionMasterDao();
               lSubscriptionMasterList = lSubscriptionMasterDao.GetAll();
           
           return lSubscriptionMasterList;
       }

       public bool UpdateRegistedSubscription(SubscriptionMaster SubscriptionMasterEntity)
       {
           bool IsOperationSuccessful = false;
          
               SubscriptionMasterDao lSubscriptionMasterDao = new SubscriptionMasterDao();
               IsOperationSuccessful = lSubscriptionMasterDao.Update(SubscriptionMasterEntity);
           
           return IsOperationSuccessful;
       }

       public bool RegisterNewContactRequest(ContactRequestRegister ContactRequestRegisterEntity)
       {
           bool IsOperationSuccessful = false;
           
               ContactRequestRegisterDao lContactRequestRegisterDao = new ContactRequestRegisterDao();
               IsOperationSuccessful = lContactRequestRegisterDao.Insert(ContactRequestRegisterEntity);
          
           return IsOperationSuccessful;
       }

       public bool UpdateRegisteredContactRequest(ContactRequestRegister ContactRequestRegisterEntity)
       {
           bool IsOperationSuccessful = false;
              ContactRequestRegisterDao lContactRequestRegisterDao = new ContactRequestRegisterDao();
               IsOperationSuccessful = lContactRequestRegisterDao.Update(ContactRequestRegisterEntity);
           
           return IsOperationSuccessful;
       }

       public ContactRequestRegister GetSelectedContactRequestByKey(int ContactRequestKey)
       {
             ContactRequestRegisterDao lContactRequestRegisterDao = new ContactRequestRegisterDao();
               ContactRequestRegister lContactRequestRegister;
               lContactRequestRegister = lContactRequestRegisterDao.GetByContactRequestKey(ContactRequestKey);

               if (lContactRequestRegister == null)
               {
                   return null;
               }
               else
               {
                   return lContactRequestRegister;
               }
          
       }

       public List<ContactRequestRegister> GetAllContactRequestRegister()
       {
           List<ContactRequestRegister> lContactRequestRegisterList = new List<ContactRequestRegister>();
           ContactRequestRegisterDao lContactRequestRegisterDao = new ContactRequestRegisterDao();
           lContactRequestRegisterList = lContactRequestRegisterDao.GetAll();

           return lContactRequestRegisterList;
       }
       #endregion
       #endregion Public Methods

       #region Events
       #endregion Events

       #region Private Methods
       #endregion Private Methods
   }
}
